package com.iob.coin.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author: GuoXinyuan
 * @Date: 2021/6/6
 */
@Data
//@AllArgsConstructor
@NoArgsConstructor
public class Triple {

    public Triple(String uri, String label_ZH, String label_EN, Node source, Node target) {
        this.uri = uri;
        this.label_ZH = label_ZH;
        this.label_EN = label_EN;
        this.source = source;
        this.target = target;
    }

    int id; //只有被加入KG时id才会产生意义

    String uri;

    String label_ZH;

    String label_EN;

    int sourceId;

    int targetId;

    @JsonIgnore
    Node source;

    @JsonIgnore
    Node target;

    @Override
    public int hashCode() {
        return uri.hashCode();
    }

    @Override
    public boolean equals(Object o){
        if(o instanceof Triple){
            Triple triple = (Triple) o;
            return triple.getUri().equals(this.uri) &&
                    triple.getSource().getUri().equals(this.source.getUri()) &&
                    triple.getTarget().getUri().equals(this.target.getUri());
        }
        else return false;
    }

}
